# Create a table for key odds ratio interpretations
key_interpretations <- data.frame(
Variable = character(),
Medium_OR = character(),
High_OR = character(),
Interpretation = character(),
stringsToSep = NULL
)
# Add Years interpretation if present
if ("Years" %in% colnames(odds_ratios)) {
key_interpretations <- rbind(key_interpretations, data.frame(
Variable = "Years in league",
Medium_OR = sprintf("%.2f", odds_ratios["MediumSalary", "Years"]),
High_OR = sprintf("%.2f", odds_ratios["HighSalary", "Years"]),
Interpretation = paste0("Each additional year of experience multiplies the odds of medium salary by ",
sprintf("%.2f", odds_ratios["MediumSalary", "Years"]),
" and high salary by ",
sprintf("%.2f", odds_ratios["HighSalary", "Years"]),
". Experience strongly influences compensation.")
))
}
# Add Career Home Runs interpretation if present
if ("CHmRun" %in% colnames(odds_ratios)) {
key_interpretations <- rbind(key_interpretations, data.frame(
Variable = "Career Home Runs",
Medium_OR = sprintf("%.3f", odds_ratios["MediumSalary", "CHmRun"]),
High_OR = sprintf("%.3f", odds_ratios["HighSalary", "CHmRun"]),
Interpretation = paste0("Each additional career home run multiplies the odds of medium salary by ",
sprintf("%.3f", odds_ratios["MediumSalary", "CHmRun"]),
" and high salary by ",
sprintf("%.3f", odds_ratios["HighSalary", "CHmRun"]),
". Power hitting is valued in compensation decisions.")
))
}
# Add League interpretation if present
if ("LeagueN" %in% colnames(odds_ratios)) {
key_interpretations <- rbind(key_interpretations, data.frame(
Variable = "League (National vs American)",
Medium_OR = sprintf("%.2f", odds_ratios["MediumSalary", "LeagueN"]),
High_OR = sprintf("%.2f", odds_ratios["HighSalary", "LeagueN"]),
Interpretation = paste0("Playing in the National League (vs American) multiplies the odds of medium salary by ",
sprintf("%.2f", odds_ratios["MediumSalary", "LeagueN"]),
" and high salary by ",
sprintf("%.2f", odds_ratios["HighSalary", "LeagueN"]),
". ", ifelse(odds_ratios["HighSalary", "LeagueN"] > 1,
"National League players tend to earn more, controlling for other factors.",
"American League players tend to earn more, controlling for other factors."))
))
}
# Add another significant variable if available
if (length(significant_high) >= 4) {
var_to_add <- significant_high[4]
if (!(var_to_add %in% c("Years", "CHmRun", "LeagueN")) && var_to_add %in% colnames(odds_ratios)) {
key_interpretations <- rbind(key_interpretations, data.frame(
Variable = var_to_add,
Medium_OR = sprintf("%.3f", odds_ratios["MediumSalary", var_to_add]),
High_OR = sprintf("%.3f", odds_ratios["HighSalary", var_to_add]),
Interpretation = paste0("Each additional unit of ", var_to_add, " multiplies the odds of medium salary by ",
sprintf("%.3f", odds_ratios["MediumSalary", var_to_add]),
" and high salary by ",
sprintf("%.3f", odds_ratios["HighSalary", var_to_add]), ".")
))
}
}
# Display the interpretations table
knitr::kable(key_interpretations,
caption = "Key Odds Ratio Interpretations",
col.names = c("Variable", "Medium Salary OR", "High Salary OR", "Interpretation"),
align = c("l", "c", "c", "l"),
format = "html") %>%
kableExtra::kable_styling(bootstrap_options = c("striped", "hover", "condensed"),
full_width = TRUE,
position = "center") %>%
kableExtra::row_spec(0, background = "#f8f9fa", bold = TRUE) %>%
kableExtra::column_spec(4, width = "50%")